<?php
require_once("database.php");
class xl_education extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from education limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from education";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($uid)
	{
		$ccid = intval($ccid);

		$sql = "select * from education where uid = '$uid'";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	
	function xem_current($uid)
	{
		$ccid = intval($ccid);

		$sql = "select * from education where uid = '$uid' limit 0,1";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	
	function xoa($uid, $scid, $clid, $ccid)
	{
		$ccid = intval($ccid);

		$sql = "delete from education where uid = '$uid', scid = '$scid', clid = '$clid', ccid = '$ccid'";
		$this->setQuery($sql);
		$this->query();
	}
	function them($year, $type)
	{
		$type = addslashes($type);

		$sql = "INSERT INTO education(year,type) VALUES ('$year','$type')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($uid, $scid, $clid, $ccid, $year, $type)
	{
		$ccid = intval($ccid);
		$type = addslashes($type);

		$sql ="UPDATE education SET year= '$year', type= '$type' WHERE uid = '$uid', scid = '$scid', clid = '$clid', ccid = '$ccid'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from education where	$type like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>